<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>phy-prepare</title>
    <link rel="stylesheet" href="/admin/layui-v2.4.5/layui/css/layui.css" media="all">
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script src="/admin/layui-v2.4.5/layui/layui.js" charset="utf-8"></script>
    <script src="/js/phyexam/phyeaxm.js"></script>
    <script src="/js/phyexam/phy-examination.js"></script>
    <!--<script type="text/html" id="editBar">
        <a class="layui-btn layui-btn-xs edit" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs delete" lay-event="del">删除</a>
    </script>-->
    <script type="text/html" id="editBar">
        <!--<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script>
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#result'
                , url: '/allResult'
                , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                , limit: 5
                , page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']//自定义分页布局
                    , limits: [5, 10, 15]
                    , first: false //不显示首页
                    , last: false //不显示尾页
                }
                // , toolbar: 'default'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'id', title: 'ID', sort: true}
                    , {field: 'num', title: '学号', sort: true}
                    , {field: 'stuName', title: '姓名'} //width 支持：数字、百分比和不填写。你还可以通过 minWidth 参数局部定义当前单元格的最小宽度，layui 2.2.1 新增
                    , {field: 'age', title: '年龄', sort: true}
                    , {field: 'sex', title: '性别'}
                    , {field: 'contact', title: '联系方式'}
                    , {field: 'deptName', title: '所属院系'}
                    , {field: 'proName', title: '项目'}
                    , {field: 'result', title: '结果', edit: 'text'}
                    // , {field: 'qualify', title: '是否合格', align: 'center'}
                    // , {field: 'classify', title: '职业', align: 'center'} //单元格内容水平居中
                    // , {field: 'experience', title: '积分', sort: true, align: 'right'} //单元格内容水平居中
                    // , {field: 'score', title: '评分', sort: true, align: 'right'}
                    , {field: 'remark', title: '备注', align: 'right'}
                    , {fixed: 'right', title: '操作', toolbar: '#editBar', width: 150}
                ]],
                id: 'result'
            });
            var $ = layui.$, active = {
                reload: function () {
                    //获取用户名
                    // var demoReload = $('#stu_search_name');
                    //执行重载
                    table.reload('result', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        //根据条件查询
                        , where: {
                            // stuName: demoReload.val()
                            key: {
                                stuName: $("#stu_search_name").val()
                            }
                        }
                    });
                }
            };
            //点击搜索按钮根据用户名称查询
            $('#search-stu').on('click',
                function () {
                    // var type = $(this).data('type');
                    // active[type] ? active[type].call(this) : '';
                    active["reload"] ? active["reload"].call(this) : '';
                });
            //监听单元格编辑
            table.on('edit(result)', function(obj){
                var value = obj.value //得到修改后的值
                    ,data = obj.data //得到所在行所有键值
                    ,field = obj.field; //得到字段
                // layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
                $.ajax({
                    url: "/updateResult",
                    type: "POST",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data:JSON.stringify({"id":data.id,
                        "value":value}),
                    success: function (e) {
                        if (e.code == 0) {
                            layer.msg("更改成功");
                        } else {
                            layer.msg("更改失败");
                        }
                    },
                    error: function (e) {
                        layer.msg(e);
                    }
                })
            });
            //监听行工具事件
            table.on('tool(result)', function(obj){
                var data = obj.data;
                console.log(obj)
                console.log(data)
                if(obj.event === 'del'){
                    layer.confirm('真的删除行么', function(index){
                        obj.del();
                        layer.close(index);
                        $.ajax({
                            url: "/deleteResult",
                            type: "POST",
                            dataType: "json",
                            contentType: "application/json; charset=utf-8",
                            data:JSON.stringify({"id":data.id}),
                            success: function (e) {
                               console.log("删除成功");
                            },
                            error: function (e) {
                                layer.msg(e);
                            }
                        })
                    });
                }
            });
        });
    </script>
</head>
<body>
<div id="nav" style="padding: 15px">
    <!-- <button id="new-dept" class="layui-btn layui-btn-fluid">开始体检</button>
     <button id="btn-add-result" class="layui-btn layui-btn-fluid">添加体检结果</button>
     <button id="show-result" class="layui-btn layui-btn-fluid">查看体检信息</button>
     <button id="back" class="layui-btn layui-btn-fluid">返回</button>-->
    <ul class="layui-nav">
        <li class="layui-nav-item"><a id="back" style="cursor: pointer">控制台</a></li>
        <li class="layui-nav-item"><a id="btn-add-result" style="cursor: pointer">添加体检结果</a></li>
        <li class="layui-nav-item"><a id="show-result" style="cursor: pointer">查看体检结果</a></li>
        <li class="layui-nav-item"><a id="manage-stu" style="cursor: pointer">学生管理</a></li>
    </ul>
</div>
<div id="temp" style="background-color: rgba(216,216,216,0.35)">
    <button id="new-dept" class="layui-btn layui-btn-normal" style="margin: 10px;">开始体检</button>
</div>
<div id="new-dept-select" style="padding: 20px; background-color: #F2F2F2; display: none;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <select id="deptSelect">
                        <option value=''>请选择体检学院</option>
                    </select>
                    <button id="btnAddPhyDept" class="layui-btn layui-btn-xs layui-btn-normal">添加体检学院</button>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="welcome">
</div>
<div id="show-add-result" style="display: none">
    <div style="padding: 20px; background-color: #F2F2F2;">
        <div class="layui-row layui-col-space15" id="add-result">
            <!--<div class="layui-col-md2">-->
            <!--<div class="layui-card">-->
            <!--<div class="layui-card-header">待体检</div>-->
            <!--<div class="layui-card-body">-->
            <!--<span class="deptName" style="width: 100%;">A学院</span></br></hr>-->
            <!--<span class="stuName">张三</span></br></hr>-->
            <!--<span class="isPhy">已体检</span>-->
            <!--<span class="deptId" style="display: none">deptId</span>-->
            <!--<span class="stuId" style="display: none">stuId</span>-->
            <!--<button id="add" class="layui-btn layui-btn-sm phyexam" class="layui-btn" style="margin-left: 25px;">录入结果</button>-->
            <!--</div>-->
            <!--</div>-->
            <!--</div>-->
        </div>
    </div>
</div>
<div id="table-result" style="display:none;background-color: rgba(216,216,216,0.35)">
    <div class="layui-inline">
        <label class="layui-form-label">学生姓名</label>
        <div class="layui-input-block">
            <!--<input id="stu_search_name" type="text" name="stu_search_name" placeholder="请输入" autocomplete="off"-->
            <!--class="layui-input">-->
            <input type="text" id="stu_search_name" name="stuName" required lay-verify="required" placeholder="请输入"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <!--<button id="search-stu" data-type="reload" class="layui-btn layuiadmin-btn-admin" lay-submit-->
        <!--lay-filter="LAY-user-back-search2">-->
        <!--<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>-->
        <!--</button>-->
        <button class="layui-btn layui-btn-normal" onclick="return false;" data-type="reload" id="search-stu">搜索
        </button>
    </div>
    <table id="result" class="layui-hide" lay-filter="result"></table>
</div>

<div id="div-manage-stu" style="display:none;">
    <!--<div style="padding: 20px; background-color: #F2F2F2;">
        <div class="layui-row layui-col-space15" id="">
            <div class="layui-col-md2">
                <div class="layui-card">
                    <div class="layui-card-header">学院信息</div>
                    <div class="layui-card-body">
                        <span class="deptName" style="width: 100%;">A学院</span></br></hr>
                        <span class="stuCount">学生人数：4个</span></br></hr>
                        <span class="deptId" style="display: none">deptId</span>
                        <button id="manage-stu" class="layui-btn layui-btn-sm phyexam" class="layui-btn" style="margin-left: 25px;">
                            学生管理
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>-->
</div>

end.
</body>
<div id="form-result" style="display: none">
    <!--<form class="layui-form" action="#" lay-filter="example">-->
    <div class="layui-form-item">
        <label class="layui-form-label">学生姓名</label>
        <div class="layui-input-block">
            <input id="stuname" type="text" name="stuname" lay-verify="title" autocomplete="off" placeholder="请输入学生姓名"
                   class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">项目A结果</label>
        <div class="layui-input-block">
            <input type="text" id="pro1" lay-verify="title" autocomplete="off" placeholder="请输入。。。"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">项目B结果</label>
        <div class="layui-input-block">
            <input type="text" id="pro2" lay-verify="title" autocomplete="off" placeholder="请输入。。。"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">项目C结果</label>
        <div class="layui-input-block">
            <input type="text" id="pro3" lay-verify="title" autocomplete="off" placeholder="请输入。。。"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">项目D结果</label>
        <div class="layui-input-block">
            <input type="text" id="pro4" lay-verify="title" autocomplete="off" placeholder="请输入。。。"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">项目E结果</label>
        <div class="layui-input-block">
            <input type="text" id="pro5" lay-verify="title" autocomplete="off" placeholder="请输入。。。"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">项目F结果</label>
        <div class="layui-input-block">
            <input type="text" id="pro6" lay-verify="title" autocomplete="off" placeholder="请输入。。。"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="sub-result" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        </div>
    </div>
    <!--</form>-->
</div>
</html>